/*
 * create by yangyang @2018-07-18
 * 此文件存放公共方法，修改请及时通知其他开发人员。
 *
 */
var baiduInfoBox
var myGeoAddress
var common = {
  /**
   * @description Date格式化
   * @param date: (Date) 日期
   * @param format: (string) 转化的格式 Y-M-D h:m:s...
   * @return (string) 转换后的日期
   */
  dateToFormat: function (date, format = 'Y-M-D h:m:s') {
    if (!date) return ''
    const formatArr = ['Y', 'M', 'D', 'h', 'm', 's']
    const dateArr = []
    dateArr.push(date.getFullYear())
    dateArr.push(date.getMonth() + 1)
    dateArr.push(date.getDate())
    dateArr.push(date.getHours())
    dateArr.push(date.getMinutes())
    dateArr.push(date.getSeconds())
    for (let i = 0, len = formatArr.length; i < len; i++) {
      format = format.replace(formatArr[i], this.fullZero(dateArr[i]))
    }
    return format
  },

  fullZero: function (num) {
    return num < 10 ? '0' + num : num
  },

  /**
   * 功能：写入cookie
   * @param1 name: cookie名称
   * @param2 value: cookie值
   * @param3 hours: 有效期，默认7天
   */
  setCookie: function (name, value, hours) {
    var exp = new Date()
    if (hours) {
      exp.setTime(exp.getTime() + hours * 60 * 60 * 1000)
    } else {
      exp.setTime(exp.getTime() + 7 * 24 * 60 * 60 * 1000) //默认7天
    }
    document.cookie = name + '=' + escape(value) + ';path=/;expires=' + exp.toGMTString()
  },
  /**
   * 功能：读取cookie
   * @param1 name: cookie名称
   *
   */
  getCookie: function (name) {
    var arr,
      reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)')
    if ((arr = document.cookie.match(reg))) return unescape(arr[2])
    else return null
  },
  /**
   * 功能：清除cookie
   * @param1 name: cookie名称
   *
   */
  clearCookie: function (name) {
    var exp = new Date()
    exp.setTime(exp.getTime() + -1 * 60 * 60 * 1000)
    document.cookie = name + '=' + escape('') + ';path=/;expires=' + exp.toGMTString()
  },
  /**
   * 功能：去除首位空格的函数
   * @param1 str: 字符串
   *
   */
  stringTrim: function (str) {
    s = str + ''
    if (!s) {
      return s
    }
    return s.replace(/(^\s*)|(\s*$)/g, '')
  },
  /**
   * 功能：保留小数点后2位
   * @param1 param: 数字或者字符串
   */
  twoDecimal: function (param) {
    if (param == 0) {
      return 0.0
    }
    if (!param) return
    param = Number(param)
    let result = 0
    if (param || param > -1) {
      result = param.toFixed(2)
    }
    return result
  },
  /**
   * 功能：数字转成带单位的数据
   * @param1 value: 数字
   */
  numberFormat: function (value) {
    var param = {data:'', size: ''}
    var k = 10000,
      sizes = ['', '万', '亿', '万亿'],
      i
    if (value < k) {
      var flag = String(value).indexOf('.')
      if (flag > 0) {
        param = {
          data: value.toFixed(2),
          size: ''
        }
      } else {
        param = {
          data: value,
          size: ''
        }
      }
    } else {
      i = Math.floor(Math.log(value) / Math.log(k))
      param = {
        data: (value / Math.pow(k, i)).toFixed(2),
        size: sizes[i]
      }
    }
    return param
  },
  /**
   * 功能：数字转成人民币格式
   * @param1 str: 数字或字符串
   */
  numberToRMB: function (str) {
    var newStr = ''
    var count = 0
    str = str + ''
    // 当数字是整数
    if (str.indexOf('.') == -1) {
      for (var i = str.length - 1; i >= 0; i--) {
        if (count % 3 == 0 && count != 0) {
          newStr = str.charAt(i) + ',' + newStr
        } else {
          newStr = str.charAt(i) + newStr
        }
        count++
      }
      str = newStr
      return str
    }
    // 当数字带有小数
    else {
      for (var i = str.indexOf('.') - 1; i >= 0; i--) {
        if (count % 3 == 0 && count != 0) {
          newStr = str.charAt(i) + ',' + newStr
        } else {
          newStr = str.charAt(i) + newStr //逐个字符相接起来
        }
        count++
      }
      str = newStr + (str + '00').substr((str + '00').indexOf('.'), 3)
      return str
    }
  },
  /**
   * 功能：数字转成人民币格式
   * @param1 element: 元素选择器
   * @param1 options: {time:动画总时间,num:要显示的真实数值}
   *
   */
  NumberGrow: function (element, options) {
    options = options || {}
    var $this = $(element),
      time = options.time || $this.data('time'), //总时间
      num = options.num || $this.data('value'), //要显示的真实数值
      step = (num * 64) / (time * 1000), //每16ms增加的数值
      start = 0, //计数器
      interval, //定时器
      old = 0
    if (interval) {
      clearInterval(interval)
    }
    //每帧不能超过16ms，所以理想的interval间隔为16ms
    //step为每16ms增加的数值
    if (!num || num < 0) {
      $this.html('0')
      return
    }
    interval = setInterval(function () {
      start = start + step
      if (start >= num) {
        clearInterval(interval)
        interval = undefined
        start = num
      }
      var t = Math.floor(start)
      if (t == old) {
        return
      }
      old = t
      $this.html(common.numberToRMB(old))
    }, 16)
  },
  /**
   * 功能：初始化日期插件(单个时间)
   * @param1 ele: 元素选择器
   * @param2 type: 时间格式   type = 0:yyyy-mm-dd hh:ii:ss; type = 1:yyyy-mm-dd
   */
  initDatePicker: function (ele, type) {
    var formatType, viewNumber
    if (type === 0) {
      formatType = 'yyyy-mm-dd hh:ii:ss'
      viewNumber = 0
    } else if (type === 1) {
      formatType = 'yyyy-mm-dd'
      viewNumber = 2
    }
    $(ele).datetimepicker({
      //时间插件
      format: formatType,
      language: 'zh-CN',
      autoclose: true,
      minView: viewNumber
    })
  },
  /**
   * 功能：时间戳转化为时间 yyyy-MM-dd HH:mm:ss
   * @param1 Date: 时间戳
   */
  getTimeMmss: function (Date) {
    var year = Date.getFullYear()
    var month = Date.getMonth() + 1 < 10 ? '0' + (Date.getMonth() + 1) : Date.getMonth() + 1
    var day = Date.getDate() < 10 ? '0' + Date.getDate() : Date.getDate()
    var hour = Date.getHours() < 10 ? '0' + Date.getHours() : Date.getHours()
    var minute = Date.getMinutes() < 10 ? '0' + Date.getMinutes() : Date.getMinutes()
    var second = Date.getSeconds() < 10 ? '0' + Date.getSeconds() : Date.getSeconds()
    return year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second
  },
  /**
   * 功能：时间戳转化为时间 yyyy-MM-dd
   * @param1 date 时间戳
   */
  getTimeDay: function (date) {
    var year = date.getFullYear()
    var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
    var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
    return year + '-' + month + '-' + day
  },
    /**
   * 功能：时间戳转化为时间 HH:mm
   * @param1 date 时间戳
   */
  getTimeHm: function (Date) {
    var hour = Date.getHours() < 10 ? '0' + Date.getHours() : Date.getHours()
    var minute = Date.getMinutes() < 10 ? '0' + Date.getMinutes() : Date.getMinutes()
    return hour + ':' + minute
  },
  /**
   * 功能：时间戳转化为时间 HH:mm:ss
   * @param1 date 时间戳
   */
  getTimeHms: function (Date) {
    var hour = Date.getHours() < 10 ? '0' + Date.getHours() : Date.getHours()
    var minute = Date.getMinutes() < 10 ? '0' + Date.getMinutes() : Date.getMinutes()
    var second = Date.getSeconds() < 10 ? '0' + Date.getSeconds() : Date.getSeconds()
    return hour + ':' + minute + ':' + second
  },
  /**
   * 功能：时间 格式yyyy-MM-dd HH:mm:ss 转换成时间戳
   * @param1 date 时间戳
   */
  mmsstoTimestamp: function (date) {
    let Tdate = date.replace(/-/g, '/')
    let timestamp = new Date(Tdate).getTime()
    return timestamp
  },
  /**
   *  功能：时间秒转化为具体时间（xx天xx时xx分xx秒）
   *  @param1 result: 秒
   */
  secondToDate: function (result) {
    var d = Math.floor(result / 86400)
    var h = Math.floor((result / 3600) % 24)
    var m = Math.floor((result / 60) % 60)
    var s = Math.floor(result % 60)
    if (Math.floor(result / 86400) > 0) {
      return d + '天' + h + '时' + m + '分' + s + '秒'
    } else if (Math.floor((result / 3600) % 24) > 0) {
      return h + '时' + m + '分' + s + '秒'
    } else if (Math.floor((result / 60) % 60) > 0) {
      return m + '分' + s + '秒'
    } else {
      return s + '秒'
    }
  },
  millisecond: function (result) {
    var d = Math.floor(result / 86400 / 1000)
    var h = Math.floor((result / 3600 / 1000) % 24)
    var m = Math.floor((result / 60 / 1000) % 60)
    var s = Math.floor((result % (60 * 1000)) / 1000)
    if (d > 0) {
      return d + '天' + h + '时' + m + '分' + s + '秒'
    } else if (h > 0) {
      return h + '时' + m + '分' + s + '秒'
    } else if (m > 0) {
      return m + '分' + s + '秒'
    } else {
      return s + '秒'
    }
  },
  /**
   *  功能：获取当前时间（yyyy-mm-dd hh:ii:ss）
   *
   */
  getNowTime: function () {
    var date = new Date()
    var year = date.getFullYear()
    var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
    var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
    var hour = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
    var minute = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
    var second = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()

    return year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second
  },
  /**
   *  功能：获取最近几天[开始时间和结束时间值,时间往前推算]
   *  @param1 day:number 近几天，数值
   */
  getRecentDaysDateTime: function (day) {
    var daymsTime = day * 24 * 60 * 60 * 1000
    var yesterDatsmsTime = new Date().getTime() - daymsTime
    var startTime = this.getTimeMmss(new Date(yesterDatsmsTime))
    var pastDate = this.getTimeMmss(new Date(startTime))
    var nowDate = this.getTimeMmss(new Date())
    var obj = {
      startTime: pastDate,
      endTime: nowDate
    }
    return obj
  },
  /**
   *  功能：校验时间格式（yyyy-mm-dd hh:ii:ss）
   *  @param1 date: 时间字符串
   */
  checkDateFormat: function (date) {
    var reg = /^(\d+)-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/
    var r = date.match(reg)
    if (r == null) return false
    r[2] = r[2] - 1
    var d = new Date(r[1], r[2], r[3], r[4], r[5], r[6])
    if (d.getFullYear() != r[1]) return false
    if (d.getMonth() != r[2]) return false
    if (d.getDate() != r[3]) return false
    if (d.getHours() != r[4]) return false
    if (d.getMinutes() != r[5]) return false
    if (d.getSeconds() != r[6]) return false
    return true
  },
  /**
   *  功能：校验时间格式（yyyy-mm-dd）
   *  @param1 date: 时间字符串
   */
  checkDayFormat: function (date) {
    var reg = /^(\d+)-(\d{1,2})-(\d{1,2})$/
    var r = date.match(reg)
    if (r == null) return false
    r[2] = r[2] - 1
    var d = new Date(r[1], r[2], r[3])
    if (d.getFullYear() != r[1]) return false
    if (d.getMonth() != r[2]) return false
    if (d.getDate() != r[3]) return false
    return true
  },
  /**
   *  功能：校验时间格式（时间范围校验）
   *  @param1 startTime: 起始时间
   *  @param1 endTime: 结束时间
   *  @param1 maxDays: 不能超过最大天数
   *
   */
  correctTimeParams: function (startTime, endTime, maxDays) {
    let result = {
      status: false,
      message: ''
    }
    if (!startTime && !endTime) {
      result.status = true
      return result
    }
    if (!startTime) {
      result.message = '开始时间不能为空'
      return result
    }
    if (!endTime) {
      result.message = '结束时间不能为空'
      return result
    }
    //判断传入进来的时间格式,分yyyy-MM-dd HH:mm:ss 和 yyyy-MM-dd两种格式校验
    var startTimeType = startTime.split(':').length
    var endTimeType = endTime.split(':').length
    if (startTimeType == endTimeType) {
      if (startTimeType !== 3) {
        if (!common.checkDayFormat(startTime)) {
          result.message = '开始时间格式不正确'
          return result
        }
        if (!common.checkDayFormat(endTime)) {
          result.message = '结束时间格式不正确'
          return result
        }
      } else {
        if (!common.checkDateFormat(startTime)) {
          result.message = '开始时间格式不正确'
          return result
        }
        if (!common.checkDateFormat(endTime)) {
          result.message = '结束时间格式不正确'
          return result
        }
      }
    } else {
      result.message = '开始时间与结束时间格式不对应'
      return result
    }
    //校验时间跨度是否在允许时间范围内
    let startTimestamp = new Date(startTime).getTime()
    let endTimestamp = new Date(endTime).getTime()
    let timeDiff = endTimestamp - startTimestamp
    if (timeDiff < 0) {
      result.message = '时间选择不正确,结束时间应大于起始时间'
      return result
    }
    if (maxDays > 0 && timeDiff > maxDays * 24 * 60 * 60 * 1000) {
      result.message = '时间区间不能超过' + maxDays + '天'
      return result
    }
    result.status = true
    return result
  },
  /**
   * 功能：导出报表
   * @param1 params 参数：json对象
   * @param2 paramsName
   * @param3 url: 接口
   */
  exprotDataFile: function (params, paramsName, url) {
    params.token = localStorage.getItem('token') || ''
    var form = $('<form>') //定义一个form表单
    form.attr('style', 'display:none')
    form.attr('target', '')
    form.attr('method', 'post')
    form.attr('action', url)
    var fileInput = $('<input>')
    fileInput.attr('type', 'hidden')
    fileInput.attr('id', 'fileName') //设置属性的名字
    fileInput.attr('name', paramsName || 'param') //设置属性的名字
    fileInput.attr('value', JSON.stringify(params)) //设置属性的值
    $('body').append(form) //将表单放置在web中
    form.append(fileInput)
    form.submit() //表单提交
    form.remove()
  },
  /**
   * 功能：效验是否传时间
   * @param1 params: 参数对象
   * @param2 ignoreCode: 忽略参数字段数组
   * @param3 givenField: 特定时间字段
   */
  correctTime: function (params, ignoreCode, givenField) {
    let result = {
      status: false,
      message: '请选择时间段导出'
    }
    givenField = givenField ? givenField : ['startTime', 'endTime']
    let timeStatus = false
    for (let key in params) {
      if (params[key]) {
        let noIgnore = ignoreCode
          ? ignoreCode.some(item => {
              return key == item
            })
          : false
        if (noIgnore) {
          continue
        }
        result.status = true
        if (key == givenField[0] || key == givenField[1]) {
          timeStatus = true
        }
        break
      }
    }
    if (timeStatus) {
      if (!params[givenField[0]]) {
        result.status = false
        result.message = '开始时间不能为空'
      }
      if (!params[givenField[1]]) {
        result.status = false
        result.message = '结束时间不能为空'
      }
    }
    return result
  },
  //获取echart折线图 线的颜色
  lineGetColor: function (sort) {
    var colorArr = [
      '#2f4554',
      '#61a0a8',
      '#d48265',
      '#91c7ae',
      '#749f83',
      '#ca8622',
      '#bda29a',
      '#6e7074',
      '#546570',
      '#c4ccd3'
    ]
    var numver = sort % colorArr.length
    return colorArr[numver]
  },
  /**
   * 功能：计算两个经纬度点之间的距离
   * @param1 point1: 经纬度1  {lng:xx,lat:xx}
   * @param2 point2: 经纬度2  {lng:xx,lat:xx}
   */
  caculationDistance: function (point1, point2) {
    var lng1 = point1.lng
    var lat1 = point1.lat
    var lat2 = point2.lat
    var lng2 = point2.lng
    EARTH_RADIUS = 6371393 //地球半径(米)
    radLat1 = (lat1 * Math.PI) / 180.0
    radLat2 = (lat2 * Math.PI) / 180.0
    a = radLat1 - radLat2
    b = ((lng1 - lng2) * Math.PI) / 180.0
    s =
      2 *
      Math.asin(
        Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))
      )
    s = s * EARTH_RADIUS
    return s
  },
  /**
   * 功能：根据经纬度反编译行政地址，依赖于百度地图
   * @param1 point:经纬度  {lng:xx,lat:xx}
   */
  pointGetAdress: function (point) {
    myGeoAddress = new BMap.Geocoder()
    return new Promise(function (resolve, reject) {
      myGeoAddress.getLocation(
        new BMap.Point(point.lng ? point.lng : point.x, point.lat ? point.lat : point.y),
        function (result) {
          if (result) {
            resolve(result.address)
          }
        }
      )
    })
  },

  /**
   * 功能：创建infoBox元素,并在地图上打开
   * @param1 baiduMap：map对象，依赖于百度地图
   * @param2 infoData：车辆定位信息，必须包含设备ID
   * @param3 baseURL：baseURL
   */
  createInfoBox: function (baiduMap, infoData, baseURL) {
    if (baiduInfoBox) {
      baiduInfoBox.close()
    }
    let reqUrl = baseURL + 'realtime/getRealTimeDataForBase.html'
    let reqdata = {
      deviceId: infoData.deviceId
    }
    let weightUnit = ' 吨',
      deviceInfoData = {}
    $.ajax({
      type: 'POST',
      data: reqdata,
      url: reqUrl,
      dataType: 'json',
      async: false,
      xhrFields: {
        withCredentials: true
      },
      timeout: 30000,
      success: function (result) {
        deviceInfoData = result.data
        deviceInfoData.unit == '2' ? (weightUnit = ' kg') : (weightUnit = ' 吨')
      }
    })
    infoData.uploadDate = infoData.uploadDate ? infoData.uploadDate : infoData.gpsUploadDate
    common.pointGetAdress(infoData).then(function (address) {
      var html =
        '<div class="infoBox">' +
        '<a></a>' +
        '<div class="content">' +
        '<ul>' +
        '<li><span class="leftSpan">公司名称：</span><span class="rightSpan"> ' +
        deviceInfoData.companyName +
        '</span></li>' +
        '<li><span class="leftSpan">当前重量：</span><span class="rightSpan"> ' +
        common.twoDecimal(infoData.weight) +
        weightUnit +
        '</span></li>' +
        '<li><span class="leftSpan">当前速度：</span><span class="rightSpan"> ' +
        infoData.speed +
        ' km/h</span></li>' +
        '<li><span class="leftSpan">经纬度值：</span><span class="rightSpan"> ' +
        infoData.x +
        ',' +
        infoData.y +
        '</span></li>' +
        '<li><span class="leftSpan">更新时间：</span><span class="rightSpan"> ' +
        infoData.uploadDate +
        '</span></li>' +
        '<li><span class="leftSpan">当前位置：</span><span class="rightSpan"> ' +
        address +
        '</span></li>' +
        '</ul>' +
        '</div>' +
        '</div>'
      var opts = {
        width: 200, // 信息窗口宽度
        title: deviceInfoData.carNumber + ' [ ID ' + deviceInfoData.deviceId + ']' // 信息窗口标题
      }
      var infoWindow = new BMap.InfoWindow(html, opts) // 创建信息窗口对象
      var point = new BMap.Point(infoData.lng, infoData.lat)
      baiduMap.openInfoWindow(infoWindow, point) //开启信息窗口
      setTimeout(function () {
        if ($('.pointer').length < 1) {
          $('.BMap_bottom').append('<div class="pointer"></div>')
        }
      }, 50)
    })
  },
  closeInfoBox: function () {
    baiduInfoBox.close()
  }
}

var treeChart = {
  initTreeData: function (data) {
    var companylist = []
    var lv2Companylist = []
    //公司id获取对应的公司下面的车辆
    function getCar(obj) {
      var result = {
        carArr: [],
        onlineCar: 0,
        allCar: 0
      }
      for (var i = 0; i < data.length; i++) {
        var item = data[i]
        if (item.remark == 'car' && item.parent == obj.id) {
          result.carArr.push(item)
          result.allCar = result.allCar + 1
          if (item.icon == 'fa fa-car online') {
            result.onlineCar = result.onlineCar + 1
          }
        }
      }
      return result
    }
    //获取公司个数
    var len = data.length
    for (var i = 0; i < len; i++) {
      data[i].state.opened = true
      if (data[i].remark == 'company') {
        let findCar = getCar(data[i])
        if (data[i].parent == '#') {
          let obj = {
            lv1: data[i],
            lv2: [],
            isOpen: false,
            car: findCar.carArr,
            allCar: findCar.allCar,
            onlineCar: findCar.onlineCar
          }
          companylist.push(obj)
        } else {
          data[i].car = findCar.carArr
          data[i].allCar = findCar.allCar
          data[i].onlineCar = findCar.onlineCar
          ;(data[i].isOpen = false), lv2Companylist.push(data[i])
        }
      }
    }
    //将二级公司置放到对应的一级公司下面
    for (var i = 0; i < companylist.length; i++) {
      let iem = companylist[i]
      for (var _i = 0; _i < lv2Companylist.length; _i++) {
        let item = lv2Companylist[_i]
        if (iem.lv1.id == item.parent) {
          iem.allCar = iem.allCar + item.allCar
          iem.onlineCar = iem.onlineCar + item.onlineCar
          iem.lv2.push(item)
        }
      }
      if (iem.lv2.length > 0) {
        iem.isOpen = true
      }
    }
    var carTreeData = companylist
    var result = {
      carTreeData: carTreeData
    }
    return result
  },
  openTree: function (data) {
    for (var i = 0; i < data.length; i++) {
      var item = data[i]
      item.lv1.state.opened = true
      item.isOpen = true
      var lv2len = item.lv2.length
      if (lv2len > 0) {
        for (let _i = 0; _i < item.lv2.length; _i++) {
          var iem = item.lv2[_i]
          iem.state.opened = true
          iem.isOpen = true
          for (let i_ = 0; i_ < iem.car.length; i_++) {
            var iem_ = iem.car[i_]
            iem_.state.opened = true
          }
        }
      }
      for (let j = 0; j < item.car.length; j++) {
        var _item = item.car[j]
        _item.state.opened = true
      }
    }
  },
  closeTree: function (data) {
    for (let i = 0; i < data.length; i++) {
      var item = data[i]
      item.lv1.state.opened = true
      item.isOpen = false
      var lv2len = item.lv2.length
      if (lv2len > 0) {
        item.isOpen = true
        for (let _i = 0; _i < item.lv2.length; _i++) {
          var iem = item.lv2[_i]
          iem.state.opened = true
          iem.isOpen = false
          for (let i_ = 0; i_ < iem.car.length; i_++) {
            var iem_ = iem.car[i_]
            iem_.state.opened = false
          }
        }
      }
      for (let j = 0; j < item.car.length; j++) {
        var _item = item.car[j]
        _item.state.opened = false
      }
    }
  },
  onlineCar: function (data) {
    var isAllnot = true //判断是否所有子公司都没有在线车辆
    for (var i = 0; i < data.length; i++) {
      var item = data[i]
      var lv2len = item.lv2.length
      item.isOpen = true
      var lv1Car = 0 //一级公司下的在线车辆
      if (lv2len > 0) {
        for (let _i = 0; _i < item.lv2.length; _i++) {
          var iem = item.lv2[_i]
          var onlineCar = 0
          for (let i_ = 0; i_ < iem.car.length; i_++) {
            var iem_ = iem.car[i_]
            if (iem_.icon == 'fa fa-car offline') {
              iem_.state.opened = false
            } else {
              iem_.state.opened = true
              onlineCar = onlineCar + 1
            }
          }
          if (onlineCar < 1) {
            iem.isOpen = true
            iem.state.opened = false
          } else {
            isAllnot = false
          }
        }
        if (isAllnot) {
          item.lv1.state.opened = false
        }
      }
      for (let j = 0; j < item.car.length; j++) {
        let _item = item.car[j]
        if (_item.icon == 'fa fa-car online') {
          _item.state.opened = true
          lv1Car = lv1Car + 1
        } else {
          _item.state.opened = false
        }
      }
      if (lv1Car < 1 && lv2len < 1) {
        item.lv1.state.opened = false
      } else {
        if (isAllnot) {
          item.lv1.state.opened = false
        } else {
          item.lv1.state.opened = true
        }
      }
      if (lv1Car > 0) {
        item.lv1.state.opened = true
      }
    }
    return isAllnot
  },
  openCarlist: function (param) {
    for (var i = 0; i < param.car.length; i++) {
      param.car[i].state.opened = true
    }
    if (param.isOpen) {
      param.isOpen = false
    } else {
      param.isOpen = true
    }
  },
  queryCar: function (queryString, data) {
    $('.searchPosition').removeClass('searchPosition')
    var resultId = ''
    return new Promise(function (resolve, reject) {
      var isFind = false
      for (let i = 0; i < data.length; i++) {
        var item = data[i]
        let valStar1 = item.lv1.text
        if (valStar1 !== '' && valStar1.match(queryString + '.*')) {
          resultId = item.id
          //					break;
        }
        var lv2len = item.lv2.length
        if (lv2len > 0) {
          for (let _i = 0; _i < item.lv2.length; _i++) {
            var iem = item.lv2[_i]
            iem.isOpen = false
            for (let i_ = 0; i_ < iem.car.length; i_++) {
              var iem_ = iem.car[i_]
              let valStar = iem_.text
              if (valStar !== '' && valStar.match(queryString + '.*')) {
                resultId = iem_.id
                for (let p = 0; p < iem.car.length; p++) {
                  iem.car[p].state.opened = true
                }
                item.isOpen = true
                iem.isOpen = true
                isFind = true
                //								break;
              }
            }
            //						if(isFind){
            //							break
            //						}
          }
        }
        for (let j = 0; j < item.car.length; j++) {
          var _item = item.car[j]
          let valStar = _item.text
          if (valStar !== '' && valStar.match(queryString + '.*')) {
            for (let p = 0; p < item.car.length; p++) {
              item.car[p].state.opened = true
            }
            resultId = _item.id
            item.isOpen = true
            isFind = true
            //						break;
          }
        }
        //				if(isFind){
        //					break;
        //				}
      }
      resolve(resultId)
    })
  },
  queryCarPositon: function (queryString) {
    var findCount = 0
    $('.getSeach').each(function (index, obj) {
      let valStar = common.stringTrim($(this).text())
      if (valStar !== '' && valStar.match(queryString + '.*')) {
        findCount = findCount + 1
        $(this).addClass('searchPosition')
      }
    })
    //		$('.searchPosition').each(function(index,obj){
    //			var container = $('.treeBody');
    //			var scrollTo = $(this);
    //			container.scrollTop(
    //				scrollTo.offset().top - container.offset().top + container.scrollTop()
    //			);
    //			container.animate({
    //				scrollTop: scrollTo.offset().top - container.offset().top + container.scrollTop() - $('.divTree').height() * 0.3
    //			});
    //			return false;
    //		})
    var messageString = '搜索出' + findCount + '条相关数据'
    let result = {
      findCount: findCount,
      messageString: messageString
    }
    return result
  },
  treePositionItem: function (index) {
    let container = $('.treeBody')
    let _this = $('.treeBody').find('.searchPosition').eq(index)
    $('.boldFont').removeClass('boldFont')
    _this.addClass('boldFont')
    let top = _this.offset().top - container.offset().top + container.scrollTop()
    container.animate({
      scrollTop: top - 100
    })
    let findString = index + 1 + '/' + $('.treeBody').find('.searchPosition').length
    return findString
  }
}

const problemOptions = {
  initProTypeOptions: [
    {
      name: '算法',
      childs: [
        {
          name: '上货问题',
          phenomenon: [
            {
              name: '上货误判',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '未识别上货',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '上货波动',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '多次上货问题',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '上货过程中归零',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            }
          ]
        },
        {
          name: '卸货问题',
          phenomenon: [
            {
              name: '卸货未及时归零',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '卸货过程中有上升',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '卸货清零后波动',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '提前卸货',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '卸货时间小于传感器时间',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '过完磅清零',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '延时卸货',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            }
          ]
        },
        {
          name: '在途问题',
          phenomenon: [
            {
              name: '途中增重量',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '途中掉重量',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            }
          ]
        }
        // {
        // 	name: '其他',
        // 	phenomenon: null,
        // },
      ]
    },
    {
      name: '硬件',
      childs: [
        {
          name: '主机问题',
          phenomenon: [
            {
              name: '离线',
              //维修指导
              repairGuide: [
                {
                  index: 1,
                  name: '检查GPSRS灯是否正常'
                },
                {
                  index: 2,
                  name: '手机连接主机蓝牙，检查ID和计数器是否正常'
                },
                {
                  index: 3,
                  name: '主机是否不断重启，检查20pin线，主线，采集器'
                },
                {
                  index: 4,
                  name: '检查保险是否工作正常'
                },
                {
                  index: 5,
                  name: '检查电源、主机工作状态等'
                }
              ],
              //维修方式
              repairWay: [
                {
                  index: 1,
                  name: '更换主机'
                },
                {
                  index: 2,
                  name: '更换SIM卡'
                },
                {
                  index: 3,
                  name: '更换20pin线'
                },
                {
                  index: 4,
                  name: '更换线材'
                },
                {
                  index: 5,
                  name: '更换保险'
                }
              ],
              //现象描述
              pheDescribe: [
                {
                  index: 1,
                  name: 'GPRS灯不正常'
                },
                {
                  index: 2,
                  name: '蓝牙连接后无ID显示或显示为0，计数器不跳'
                },
                {
                  index: 3,
                  name: '手机不能通过蓝牙连接主机'
                },
                {
                  index: 4,
                  name: '主机不断重启'
                },
                {
                  index: 5,
                  name: '其他'
                }
              ]
            },
            {
              name: '未识别上货',
              repairGuide: [
                {
                  index: 1,
                  name: '更换主机'
                }
              ],
              repairWay: [
                {
                  index: 1,
                  name: '更换主机'
                }
              ],
              pheDescribe: null
            }
          ]
        },
        {
          name: '传感器问题',
          phenomenon: [
            {
              name: '正负52万',
              repairGuide: [
                {
                  index: 1,
                  name: 'APP检查传感器是否显示极值'
                },
                {
                  index: 2,
                  name: '2000表检查传感器是否显示“EI”'
                },
                {
                  index: 3,
                  name: '更换传感器'
                }
              ],
              repairWay: [
                {
                  index: 1,
                  name: '更换传感器'
                }
              ],
              pheDescribe: [
                {
                  index: 1,
                  name: '传感器粘贴处胶松动'
                },
                {
                  index: 2,
                  name: '传感器粘贴处被破坏'
                },
                {
                  index: 3,
                  name: 'APP检测通道值显示52万'
                },
                {
                  index: 4,
                  name: '2000表检测通值异常'
                },
                {
                  index: 5,
                  name: '其他'
                }
              ]
            },
            {
              name: '偶尔52万',
              repairGuide: [
                {
                  index: 1,
                  name: 'APP检查传感器是否显示极值'
                },
                {
                  index: 2,
                  name: '2000表检查传感器是否显示“EI”'
                },
                {
                  index: 3,
                  name: '更换传感器'
                }
              ],
              repairWay: [
                {
                  index: 1,
                  name: '更换传感器'
                }
              ],
              pheDescribe: [
                {
                  index: 1,
                  name: '传感器粘贴处胶松动'
                },
                {
                  index: 2,
                  name: '传感器粘贴处被破坏'
                },
                {
                  index: 3,
                  name: 'APP检测通道值显示52万'
                },
                {
                  index: 4,
                  name: '2000表检测通值异常'
                },
                {
                  index: 5,
                  name: '其他'
                }
              ]
            },
            {
              name: '经常52万',
              repairGuide: [
                {
                  index: 1,
                  name: 'APP检查传感器是否显示极值'
                },
                {
                  index: 2,
                  name: '2000表检查传感器是否显示“EI”'
                },
                {
                  index: 3,
                  name: '更换传感器'
                }
              ],
              repairWay: [
                {
                  index: 1,
                  name: '更换传感器'
                }
              ],
              pheDescribe: [
                {
                  index: 1,
                  name: '传感器粘贴处胶松动'
                },
                {
                  index: 2,
                  name: '传感器粘贴处被破坏'
                },
                {
                  index: 3,
                  name: 'APP检测通道值显示52万'
                },
                {
                  index: 4,
                  name: '2000表检测通值异常'
                },
                {
                  index: 5,
                  name: '其他'
                }
              ]
            },
            {
              name: '超过52万',
              repairGuide: [
                {
                  index: 1,
                  name: '485接口松动或接触不良'
                },
                {
                  index: 2,
                  name: '手机连接主机蓝牙，确认通道值是否异常'
                },
                {
                  index: 3,
                  name: '检查接线、4pin接口等'
                }
              ],
              repairWay: [
                {
                  index: 1,
                  name: '更换主机'
                },
                {
                  index: 2,
                  name: '更换485接口连接线'
                },
                {
                  index: 3,
                  name: '检查接线、4pin接口等'
                }
              ],
              pheDescribe: [
                {
                  index: 1,
                  name: 'APP显示通道值异常'
                },
                {
                  index: 2,
                  name: '其他'
                }
              ]
            },
            {
              name: '零值',
              repairGuide: [
                {
                  index: 1,
                  name: '检查线材是否短路或断裂'
                },
                {
                  index: 2,
                  name: '检查采集器是否进水'
                },
                {
                  index: 3,
                  name: '检查接线、4pin接口等'
                }
              ],
              repairWay: [
                {
                  index: 1,
                  name: '更换采集器'
                },
                {
                  index: 2,
                  name: '更换线材'
                },
                {
                  index: 3,
                  name: '检查接线、4pin接口等'
                }
              ],
              pheDescribe: [
                {
                  index: 1,
                  name: 'APP显示通道值为0'
                }
              ]
            },
            {
              name: '平直',
              repairGuide: [
                {
                  index: 1,
                  name: '485接口松动或接触不良'
                },
                {
                  index: 2,
                  name: '检查接线'
                },
                {
                  index: 3,
                  name: '4pin接口'
                },
                {
                  index: 4,
                  name: '检查接线、4pin接口等'
                }
              ],
              repairWay: [
                {
                  index: 1,
                  name: '更换主机'
                },
                {
                  index: 2,
                  name: '更换485接口接连线'
                },
                {
                  index: 3,
                  name: '检查接线'
                },
                {
                  index: 4,
                  name: '4pin接口'
                },
                {
                  index: 5,
                  name: '检查接线、4pin接口等'
                }
              ],
              pheDescribe: [
                {
                  index: 1,
                  name: 'APP显示通道值不跳动'
                },
                {
                  index: 2,
                  name: '其他'
                }
              ]
            },
            {
              name: '乱跳',
              repairGuide: [
                {
                  index: 1,
                  name: 'APP检查传感器是否乱跳'
                },
                {
                  index: 2,
                  name: '2000表检查传感器是否乱跳'
                },
                {
                  index: 3,
                  name: '更换传感器'
                }
              ],
              repairWay: [
                {
                  index: 1,
                  name: '更换传感器'
                }
              ],
              pheDescribe: [
                {
                  index: 1,
                  name: '传感器粘贴处胶松动'
                },
                {
                  index: 2,
                  name: '传感器粘贴处被破坏'
                },
                {
                  index: 3,
                  name: 'APP检测传感器乱跳'
                },
                {
                  index: 4,
                  name: '2000表检测通值异常'
                },
                {
                  index: 5,
                  name: '其他'
                }
              ]
            },
            {
              name: '方向反',
              repairGuide: [
                {
                  index: 1,
                  name: '更换传感器'
                }
              ],
              repairWay: [
                {
                  index: 1,
                  name: '更换传感器'
                }
              ],
              pheDescribe: []
            },
            {
              name: '形变小',
              repairGuide: [
                {
                  index: 1,
                  name: '更换传感器'
                }
              ],
              repairWay: [
                {
                  index: 1,
                  name: '更换传感器'
                }
              ],
              pheDescribe: []
            }
          ]
        },
        {
          name: 'GPS问题',
          phenomenon: [
            {
              name: 'GPS丢失',
              repairGuide: [
                {
                  index: 1,
                  name: '检查gps天线是否被遮挡'
                },
                {
                  index: 2,
                  name: '检查GPS天线是否破损'
                },
                {
                  index: 3,
                  name: '检查天线'
                }
              ],
              repairWay: [
                {
                  index: 1,
                  name: '更换天线'
                },
                {
                  index: 2,
                  name: '更换终端'
                },
                {
                  index: 3,
                  name: '将天线转移至车顶'
                },
                {
                  index: 4,
                  name: '检查天线'
                },
                {
                  index: 5,
                  name: '检查天线'
                }
              ],
              pheDescribe: [
                {
                  index: 1,
                  name: '司机遮挡天线'
                },
                {
                  index: 2,
                  name: 'GPS天线破损'
                },
                {
                  index: 3,
                  name: '其他'
                },
                {
                  index: 4,
                  name: '检查天线'
                }
              ]
            },
            {
              name: 'GPS漂移',
              repairGuide: [
                {
                  index: 1,
                  name: '检查gps天线是否被遮挡'
                },
                {
                  index: 2,
                  name: '检查GPS天线是否破损'
                },
                {
                  index: 3,
                  name: '检查天线'
                }
              ],
              repairWay: [
                {
                  index: 1,
                  name: '更换天线'
                },
                {
                  index: 2,
                  name: '更换终端'
                },
                {
                  index: 3,
                  name: '将天线转移至车顶'
                },
                {
                  index: 4,
                  name: '检查天线'
                }
              ],
              pheDescribe: [
                {
                  index: 1,
                  name: '司机遮挡天线'
                },
                {
                  index: 2,
                  name: 'GPS天线破损'
                },
                {
                  index: 3,
                  name: '其他'
                }
              ]
            },
            {
              name: '停车速度平直',
              repairGuide: [
                {
                  index: 1,
                  name: '检查gps天线是否被遮挡'
                },
                {
                  index: 2,
                  name: '检查GPS天线是否破损'
                },
                {
                  index: 3,
                  name: '检查天线'
                }
              ],
              repairWay: [
                {
                  index: 1,
                  name: '更换天线'
                },
                {
                  index: 2,
                  name: '更换终端'
                },
                {
                  index: 3,
                  name: '将天线转移至车顶'
                },
                {
                  index: 4,
                  name: '检查天线'
                }
              ],
              pheDescribe: [
                {
                  index: 1,
                  name: '司机遮挡天线'
                },
                {
                  index: 2,
                  name: 'GPS天线破损'
                },
                {
                  index: 3,
                  name: '其他'
                }
              ]
            },
            {
              name: '无GPS',
              repairGuide: [
                {
                  index: 1,
                  name: '检查gps天线是否被遮挡'
                },
                {
                  index: 2,
                  name: '检查GPS天线是否破损'
                },
                {
                  index: 3,
                  name: '检查天线'
                }
              ],
              repairWay: [
                {
                  index: 1,
                  name: '更换天线'
                },
                {
                  index: 2,
                  name: '更换终端'
                },
                {
                  index: 3,
                  name: '将天线转移至车顶'
                },
                {
                  index: 4,
                  name: '检查天线'
                }
              ],
              pheDescribe: [
                {
                  index: 1,
                  name: '司机遮挡天线'
                },
                {
                  index: 2,
                  name: 'GPS天线破损'
                },
                {
                  index: 3,
                  name: '其他'
                }
              ]
            },
            {
              name: '大段丢失',
              repairGuide: [
                {
                  index: 1,
                  name: '检查gps天线是否被遮挡'
                },
                {
                  index: 2,
                  name: '检查GPS天线是否破损'
                },
                {
                  index: 3,
                  name: '检查天线'
                }
              ],
              repairWay: [
                {
                  index: 1,
                  name: '更换天线'
                },
                {
                  index: 2,
                  name: '更换终端'
                },
                {
                  index: 3,
                  name: '将天线转移至车顶'
                },
                {
                  index: 4,
                  name: '检查天线'
                }
              ],
              pheDescribe: [
                {
                  index: 1,
                  name: '司机遮挡天线'
                },
                {
                  index: 2,
                  name: 'GPS天线破损'
                },
                {
                  index: 3,
                  name: '其他'
                }
              ]
            },
            {
              name: '偶尔丢失',
              repairGuide: [
                {
                  index: 1,
                  name: '检查gps天线是否被遮挡'
                },
                {
                  index: 2,
                  name: '检查GPS天线是否破损'
                },
                {
                  index: 3,
                  name: '检查天线'
                }
              ],
              repairWay: [
                {
                  index: 1,
                  name: '更换天线'
                },
                {
                  index: 2,
                  name: '更换终端'
                },
                {
                  index: 3,
                  name: '将天线转移至车顶'
                },
                {
                  index: 4,
                  name: '检查天线'
                }
              ],
              pheDescribe: [
                {
                  index: 1,
                  name: '司机遮挡天线'
                },
                {
                  index: 2,
                  name: 'GPS天线破损'
                },
                {
                  index: 3,
                  name: '其他'
                }
              ]
            }
          ]
        },
        {
          name: '线材问题',
          phenomenon: [
            {
              name: '无通道',
              repairGuide: [
                {
                  index: 1,
                  name: '检查接线、4pin接口等'
                }
              ],
              repairWay: [
                {
                  index: 1,
                  name: '检查接线、4pin接口等'
                }
              ],
              pheDescribe: null
            },
            {
              name: '全部平直',
              repairGuide: [
                {
                  index: 1,
                  name: '检查接线、4pin接口等'
                }
              ],
              repairWay: [
                {
                  index: 1,
                  name: '检查接线、4pin接口等'
                }
              ],
              pheDescribe: null
            },
            {
              name: '过磅传感器不跳',
              repairGuide: [
                {
                  index: 1,
                  name: '检查接线、4pin接口等'
                }
              ],
              repairWay: [
                {
                  index: 1,
                  name: '检查接线、4pin接口等'
                }
              ],
              pheDescribe: null
            }
          ]
        },
        {
          name: '其他',
          phenomenon: null
        }
      ]
    },

    {
      name: '司机',
      childs: [
        {
          name: '司机问题',
          phenomenon: [
            {
              name: '上货断电',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '卸货断电',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '司机修车',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '车祸',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            }
          ]
        },
        {
          name: '其他',
          phenomenon: null
        }
      ]
    },
    {
      name: '对接',
      childs: [
        {
          name: '对接问题',
          phenomenon: [
            {
              name: '未传地磅',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '重量未乘倍数',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '进场重量不为零',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            }
          ]
        },
        {
          name: '其他',
          phenomenon: null
        }
      ]
    },
    {
      name: '运维',
      childs: [
        {
          name: '运维问题',
          phenomenon: [
            {
              name: '未升级',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '未设系数',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '未调整系数',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            }
          ]
        },
        {
          name: '未升级',
          phenomenon: null
        },
        {
          name: '系数问题',
          phenomenon: null
        },
        {
          name: '其他',
          phenomenon: null
        }
      ]
    },
    {
      name: '安装',
      childs: [
        {
          name: '安装问题',
          phenomenon: [
            {
              name: '车型录入错误',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '通道顺序连接错误',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '车牌号码录入错误',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '车辆项目录入错误',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            },
            {
              name: '设备版本录入错误',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            }
          ]
        },
        {
          name: '其他',
          phenomenon: null
        }
      ]
    },
    {
      name: '平台',
      childs: [
        {
          name: '未识别异常',
          phenomenon: [
            {
              name: '未识别异常',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            }
          ]
        },
        {
          name: '算法曲线断裂',
          phenomenon: [
            {
              name: '算法曲线断裂',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            }
          ]
        },
        {
          name: '其他',
          phenomenon: null
        }
      ]
    },
    {
      name: '磅单',
      childs: [
        {
          name: '磅单问题',
          phenomenon: [
            {
              name: '磅单异常',
              repairGuide: null,
              repairWay: null,
              pheDescribe: null
            }
          ]
        },
        {
          name: '其他',
          phenomenon: null
        }
      ]
    }
  ],
  findTypeClassbyFaultName: function (nameStr) {
    nameStr = nameStr + '问题'
    let result = {
      problemType: undefined, //问题类型
      problemClass: undefined //问题分类
    }
    for (let i = 0; i < problemOptions.initProTypeOptions.length; i++) {
      let item = problemOptions.initProTypeOptions[i]
      let len = item.childs.length
      let isFind = false
      for (let j = 0; j < len; j++) {
        let iem = item.childs[j]
        if (nameStr == iem.name) {
          result.problemType = i
          result.problemClass = j
          isFind = true
          break
        }
      }
      if (isFind) {
        return result
        break
      }
    }
  },
  findPhenomenonbyStr: function (cls, str) {
    let result = ''
    let data = problemOptions.initProTypeOptions[1].childs[cls].phenomenon
    if (data) {
      for (let i = 0; i < data.length; i++) {
        if (data[i].name == str) {
          result = i
          break
        }
      }
    }
    return result
  },
  findRepairGuidebyStr: function (cls, peh, str) {
    let result = ''
    let data = problemOptions.initProTypeOptions[1].childs[cls].phenomenon[peh].repairGuide
    if (data) {
      for (let i = 0; i < data.length; i++) {
        if (data[i].name == str) {
          result = i
          break
        }
      }
    }
    return result
  }
}

var allSelectOptionsObj = {
  /**
   * gpsOptions
   * value: option的value值
   * text: option显示的文本值
   */
  gpsOptions: [],
  /**
   * gsmOptions
   * value: option的value值
   * text: option显示的文本值
   */
  gsmOptions: []
}

/**
 * 角色分类
 * value: option的value值
 * text: option显示的文本值
 */
var roleUserType = [
  {
    id: 1,
    text: '管理员'
  },
  {
    id: 2,
    text: '公司用户'
  },
  {
    id: 3,
    text: '项目管理'
  },
  {
    id: 4,
    text: '项目实施-内部'
  },
  {
    id: 5,
    text: '项目实施-代维'
  },
  {
    id: 6,
    text: '项目实施-外包'
  },
  {
    id: 7,
    text: '客户'
  },
  {
    id: 8,
    text: '测试'
  },
  {
    id: 0,
    text: '其他'
  }
]

var carTypeListObj = {
  carTypeList: [
    {
      id: '00',
      label: '其他',
      children: [
        {
          id: '0000',
          label: '其他'
        }
      ]
    },
    {
      id: '01',
      label: '水泥车',
      children: [
        {
          id: '0100',
          label: '其他'
        },
        {
          id: '0101',
          label: '散装水泥罐车'
        },
        {
          id: '0102',
          label: '袋装水泥汽车'
        },
        {
          id: '0104',
          label: '袋装平板挂车'
        },
        {
          id: '0103',
          label: '混凝土搅拌车'
        },
        {
          id: '0105',
          label: '物资车'
        }
      ]
    },
    {
      id: '02',
      label: '环卫车',
      children: [
        {
          id: '0200',
          label: '其他'
        },
        {
          id: '0210',
          label: '后挂垃圾车[单桶]'
        },
        {
          id: '0211',
          label: '后挂垃圾车[双桶]'
        },
        {
          id: '0212',
          label: '后挂垃圾车[三桶]'
        },
        {
          id: '0213',
          label: '侧挂垃圾车[链条]'
        },
        {
          id: '0214',
          label: '侧挂垃圾车[拉杆]'
        },
        {
          id: '0203',
          label: '勾臂车垃圾车'
        },
        {
          id: '0204',
          label: '摆臂式垃圾车'
        },
        {
          id: '0208',
          label: '尾板垃圾车[8桶]'
        },
        {
          id: '0206',
          label: '尾板垃圾车[4.2M]'
        },
        {
          id: '0205',
          label: '尾板垃圾车[4.2M平板]'
        },
        {
          id: '0207',
          label: '尾板垃圾车[4.2M不封顶]'
        },
        {
          id: '0215',
          label: '压缩式垃圾车[整车]'
        },
        {
          id: '0209',
          label: '三轮垃圾车'
        }
      ]
    },
    {
      id: '03',
      label: '厢式货车',
      children: [
        {
          id: '0300',
          label: '其他'
        },
        {
          id: '0301',
          label: '箱式货车[4.2M]'
        },
        {
          id: '0302',
          label: '箱式货车[7.6M]'
        },
        {
          id: '0303',
          label: '箱式货车[9.6M]'
        },
        {
          id: '0304',
          label: '依维柯'
        }
      ]
    },
    {
      id: '04',
      label: '渣土车',
      children: [
        {
          id: '0400',
          label: '其他'
        },
        {
          id: '0401',
          label: '渣土车[2轴]'
        },
        {
          id: '0402',
          label: '渣土车[3轴]'
        },
        {
          id: '0403',
          label: '渣土车[4轴]'
        }
      ]
    },
    {
      id: '05',
      label: '挂车',
      children: [
        {
          id: '0500',
          label: '其他'
        },
        {
          id: '0501',
          label: '箱式挂车'
        },
        {
          id: '0502',
          label: '平板挂车'
        }
      ]
    },
    {
      id: '06',
      label: '煤炭车',
      children: [
        {
          id: '0601',
          label: '煤炭车'
        }
      ]
    },
    {
      id: '07',
      label: '骨料车',
      children: [
        {
          id: '0701',
          label: '骨料车'
        }
      ]
    },
    {
      id: '08',
      label: '混凝土搅拌车',
      children: [
        {
          id: '0801',
          label: '混凝土搅拌车'
        }
      ]
    }
  ],
  carTypeListTree: [
    {
      id: '00',
      text: '其他',
      state: {
        disabled: false,
        opened: true,
        selected: false
      },
      children: [
        {
          id: '0000',
          text: '其他',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        }
      ]
    },
    {
      id: '01',
      text: '水泥车',
      state: {
        disabled: false,
        opened: true,
        selected: false
      },
      children: [
        {
          id: '0100',
          text: '其他',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0101',
          text: '散装水泥罐车',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0102',
          text: '袋装水泥汽车',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0104',
          text: '袋装平板挂车',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0103',
          text: '混凝土搅拌车',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0105',
          text: '物资车',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        }
      ]
    },
    {
      id: '02',
      text: '环卫车',
      state: {
        disabled: false,
        opened: true,
        selected: false
      },
      children: [
        {
          id: '0200',
          text: '其他',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0210',
          text: '后挂垃圾车[单桶]',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0211',
          text: '后挂垃圾车[双桶]',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0212',
          text: '后挂垃圾车[三桶]',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0213',
          text: '侧挂垃圾车[链条]',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0214',
          text: '侧挂垃圾车[拉杆]',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0203',
          text: '勾臂车垃圾车',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0204',
          text: '摆臂式垃圾车',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0208',
          text: '尾板垃圾车[8桶]',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0206',
          text: '尾板垃圾车[4.2M]',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0205',
          text: '尾板垃圾车[4.2M平板]',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0207',
          text: '尾板垃圾车[4.2M不封顶]',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0215',
          text: '压缩式垃圾车[整车]',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0209',
          text: '三轮垃圾车',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        }
      ]
    },
    {
      id: '03',
      text: '厢式货车',
      state: {
        disabled: false,
        opened: true,
        selected: false
      },
      children: [
        {
          id: '0300',
          text: '其他',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0301',
          text: '箱式货车[4.2M]',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0302',
          text: '箱式货车[7.6M]',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0303',
          text: '箱式货车[9.6M]',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0304',
          text: '依维柯',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        }
      ]
    },
    {
      id: '04',
      text: '渣土车',
      state: {
        disabled: false,
        opened: true,
        selected: false
      },
      children: [
        {
          id: '0400',
          text: '其他',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0401',
          text: '渣土车[2轴]',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0402',
          text: '渣土车[3轴]',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0403',
          text: '渣土车[4轴]',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        }
      ]
    },
    {
      id: '05',
      text: '挂车',
      state: {
        disabled: false,
        opened: true,
        selected: false
      },
      children: [
        {
          id: '0500',
          text: '其他',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0501',
          text: '箱式挂车',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        },
        {
          id: '0502',
          text: '平板挂车',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        }
      ]
    },
    {
      id: '06',
      text: '煤炭车',
      state: {
        disabled: false,
        opened: true,
        selected: false
      },
      children: [
        {
          id: '0601',
          text: '煤炭车',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        }
      ]
    },
    {
      id: '07',
      text: '骨料车',
      state: {
        disabled: false,
        opened: true,
        selected: false
      },
      children: [
        {
          id: '0701',
          text: '骨料车',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        }
      ]
    },
    {
      id: '08',
      text: '混凝土搅拌车',
      state: {
        disabled: false,
        opened: true,
        selected: false
      },
      children: [
        {
          id: '0801',
          text: '混凝土搅拌车',
          state: {
            disabled: false,
            opened: true,
            selected: false
          }
        }
      ]
    }
  ],
  carUseList: {
    '00': '其他',
    '01': '水泥车',
    '02': '环卫车',
    '03': '厢式货车',
    '04': '渣土车',
    '05': '挂车',
    '06': '煤炭车',
    '07': '骨料车',
    '08': '混凝土搅拌车'
  },
  carDeatailUseList: {
    '0000': '其他',
    '0100': '其他',
    '0101': '散装水泥罐车',
    '0102': '袋装水泥汽车',
    '0104': '袋装平板车',
    '0103': '混凝土搅拌车',
    '0105': '物资车',
    '0200': '其他',
    '0210': '后挂垃圾车[单桶]',
    '0211': '后挂垃圾车[双桶]',
    '0212': '后挂垃圾车[三桶]',
    '0213': '侧挂垃圾车[链条]',
    '0214': '侧挂垃圾车[拉杆]',
    // '0201':'侧挂式垃圾车',  //该数据已删除
    // '0202':'压缩式垃圾车', //该数据已删除
    '0203': '勾臂车垃圾车',
    '0204': '摆臂式垃圾车',
    '0208': '尾板垃圾车[8桶]',
    '0206': '尾板垃圾车[4.2M]',
    '0205': '尾板垃圾车[4.2M平板]', //名字更改 旧名称：餐厨式垃圾车
    '0207': '尾板垃圾车[4.2M不封顶]',
    '0215': '压缩式垃圾车[整车]',
    '0209': '三轮垃圾车',
    '0300': '其他',
    '0301': '箱式货车[4.2M]',
    '0302': '箱式货车[7.6M]',
    '0303': '箱式货车[9.6M]',
    '0304': '依维柯',
    '0400': '其他',
    '0401': '渣土车[2轴]',
    '0402': '渣土车[3轴]',
    '0403': '渣土车[4轴]',
    '0500': '其他',
    '0501': '箱式挂车',
    '0502': '平板挂车',
    '0601': '煤炭车',
    '0701': '骨料车',
    '0801': '混凝土搅拌车'
  }
}


/**
 * 角色分类
 * value: option的value值
 * text: option显示的文本值
 */

var businessTypeList =  [
  { value: '01', label: '水泥行业' },
  { value: '02', label: '环卫行业' },
  { value: '03', label: '煤炭行业' },
  { value: '04', label: '渣土行业' },
  { value: '05', label: '冷链行业' },
  { value: '06', label: '混凝土行业' },
  { value: '07', label: '钢铁矿石行业' },
  { value: '08', label: '物流行业' },
  { value: '99', label: '其它' }
]